﻿using System.Reflection;

namespace Leo.Common
{
    public class ObjectToDictionaryEntry
    {
        private readonly object instance;

        private object _value;
        public ObjectToDictionaryEntry(object instance)
        {
            this.instance = instance;
        }

        public PropertyInfo Property { get; set; }

        public string Key { get; set; }
        public object Value
        {
            get
            {
                return this.GetValue();
            }
        }

        private object GetValue()
        {
            if (this._value == null)
            {
                this._value = this.Property.GetValue(this.instance);
            }
            return this._value;
        }
         
    }
}
